package ace.module.upms.core.impl.controller.rest.rpc.ext;

import ace.cmp.core.model.R;
import ace.cmp.security.oauth2.resource.server.core.annotation.PreAuthorizeIsInternalClient;
import ace.module.common.api.annotation.ApiRemoteImplementPriority;
import ace.module.upms.core.impl.service.UmpsAuthorityService;
import ace.module.upms.sdk.core.feign.impl.UpmsAuthorityFeign;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.Set;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 权限对象 rpc controller.
 * @author caspar
 */
@Tag(name = "权限对象-RPC-API")
@PreAuthorizeIsInternalClient
@AllArgsConstructor
@RestController
@RequestMapping(UpmsAuthorityFeign.PATH)
@ApiRemoteImplementPriority
public class UpmsAuthorityRpcController implements UpmsAuthorityFeign {

  private final UmpsAuthorityService umpsAuthorityService;

  @Override
  public R<Set<String>> getByUpmsAppIdAndAccountId(Long upmsAppId, Long accountId) {
    Set<String> authorities = umpsAuthorityService.getByUpmsAppIdAndAccountId(upmsAppId, accountId);
    return R.ok(authorities);
  }
}
